<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>test</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style type="text/css">
       h1 {font-size:16px;}
       p {font-size:14px;text-indent: 20px;}
       table{ border-collapse:collapse; }
        td{ border:1px solid #000;height:28px;line-height: 28px;}
       
    </style>
  </head>
  <body>
    <h1>1:接口名称</h1>
    <p>常量查询<br/>
    </p>
    <h1>2:接口说明</h1>
    <p></p>
    <h1>3：接口测试</h1>
    <p>
    <form name="form1" id="form1" enctype="multipart/form-data" method="post"  >
	    
	    <input type="button" value="submit" onclick='exe()'>
	</form>


	<br/>
    </p>
    
    <h1>4：pet_code常量 (宠物类型)</h1>
    <p>
    <div id="backJson">
    
    
     <table>
       <tr>
          <td style="width:120px;">code</th>
          <td style="width:480px;">常量名</th>
       </tr>
       <tbody id="pet_list">
         <tr>  <td></td><td></td> </tr>
         
       </tbody>
     
     </table>
    </div>
    <h1>cat_code常量 (商品类型 如:干粮等)</h1>
    <div>
		<table>
       <tr>
          <td style="width:120px;">code</th>
          <td style="width:480px;">常量名</th>
       </tr>
       <tbody id="cate_list">
         <tr>  <td></td><td></td> </tr>
         
       </tbody>
     
     </table>
	</div>
    
    <br/>
    <h1>ju_code常量 (综合code 如:猫咪干粮等 配合页面UIcode )</h1>
    <div>
		<table>
       <tr>
          <td style="width:120px;">code</th>
          <td style="width:480px;">常量名</th>
       </tr>
       <tbody id="ju_list">
         
         
       </tbody>
     
     </table>
	</div>
    
    
    </p>
  </body>
</html>
<script type="text/javascript" src="/js/xhr.js"></script>
<script type="text/javascript" src="/js/cactus.js"></script>
<script type="text/javascript" src="/js/util.js"></script>

<script>
    function exe(){
           //Demo.execute("/rest/2.0/product/codelist",document.forms["form1"]);
           
           new xhr("/rest/2.0/product/codelist",function(response){
        	   
        	   if(response.code==200){
        		   var _html='';
        		   _html=drawOne(response.data.mao,true);
        		   _html+=drawOne(response.data.gou,true);
        		   //_html+=drawOne(response.data.shipin);
        		   //_html+=drawOne(response.data.yongpin);
        		   document.getElementById("pet_list").innerHTML=_html;
        		   
        		   var cate_html='';
        		   cate_html=drawOne(response.data.shipin);
        		   cate_html+=drawOne(response.data.yongpin);
        		   
        		   document.getElementById("cate_list").innerHTML=cate_html;
        		   
        		   
        		   var ju_html='';
        		   ju_html=drawOne(response.data.jucode);
        		   
        		   document.getElementById("ju_list").innerHTML=ju_html;
        		   
        	   }
        	   
           }).setForm(document.forms["form1"]).execute();
    }
    
    function drawOne(c,b){
        var _html='<tr><td>'+c.cate_code+'</td><td>'+c.cate_name+'</td></tr>';
        if(b){
        	return _html;
        }else{
        	var shtml=draw(c.sub_category);
            return _html+shtml;
        }
    }
    
    function draw(data){
    	var _html='';
    	util.each(data,function(e){
    		_html+=('<tr><td>'+e.cate_code+'</td><td>'+e.cate_name+'</td></tr>');
    		_html+= draw(e.sub_category,_html);
    	});
    	return _html;
    	
    }
    
    
    
    exe();
</script>
